hook::add incoming_invite in_invite 5
set opt(invite) 1
proc in_invite {from fromjid cjid reason} {
global opt
	if {$opt(invite)==1} {
		set ifadm [ifadmin $fromjid]
		if {$ifadm>4} {
			global con name
			if {$reason==""} {
				set reason "invited by $from"
			}
			set out "<presence to='$cjid/$name(def)' xml:lang='ru'><status>$reason</status><x xmlns='http://jabber.org/protocol/muc'><history maxchars='0' maxstanzas='0'/></x></presence>"
			set name($cjid) $name(def)

			if {[lsearch -exact $con "$cjid"]==-1} {
				lappend con $cjid
			}
			jlib::outmsg $out
			return stop
		} else {
			puts ifadm<4
		}
	}
}